package org.example.mpdemo1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.mpdemo1.entity.User;

import java.util.List;


@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where id=#{id}")
    User selectById(int id);

    @Select("select * from user")
    List<User> selectAll();

    @Select("select * from user where username=#{username}")
    User selectByName(String username);

    @Select("select activationCode from user where id=#{id}")
    String getActivationCode(int id);

    @Select("select * from user where email=#{email}")
    User selectByEmail(String email);

    @Insert("insert into user(username,password,salt,email,type,status,activationCode,headerUrl,createTime) values(#{username},#{password},#{salt},#{email},#{type},#{status},#{activationCode},#{headerUrl},#{createTime})")
    int insertUser(User user);

    @Update("update user set status=#{status} where id=#{id}")
    int updateStatus(@Param("id") int id, @Param("status") int status);

    @Update("update user set headerUrl=#{headerUrl} where id=#{id}")
    int updateHeader(@Param("id") int id, @Param("headerUrl")  String headerUrl);

    @Update("update user set password=#{password} where id=#{id}")
    int updatePassword(@Param("id") int id, @Param("password") String password);

    @Select("select id from user where username=#{username}")
    int getUserIdByUsername(String username);

//    @Insert("insert into user values(#{id},#{username},#{password},#{birthday})")
//    int add(User user);
//
//    @Update("update user set username=#{username},password=#{password},birthday=#{birthday} where id=#{id}")
//    int update(User user);
//
//    @Delete("delete from user where id=#{id}")
//    int delete(int id);
//
//    @Select("select * from user where id=#{id}")
//    User findById(int id);
//
//    @Select("select * from user")
//    List<User> getAll();
}
